package com.xcw.controller;

import com.xcw.entity.req.UserRegisterParams;
import com.xcw.util.ExcelUtil;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @Author bhx
 * @Date 2022/6/28 23:15
 * @Description excel 导入导出控制类
 */
@Controller
@Slf4j
@RequestMapping("/excel")
public class ExcelController {



    @SneakyThrows
    @RequestMapping("/leadingIn")
    @ResponseBody
    public List<List<Object>> leadingIn(@RequestParam(value = "file") MultipartFile multipartFile){
        String filename = multipartFile.getOriginalFilename();
        System.out.println(filename);
        List<List<Object>> users = ExcelUtil.importExcelMultipartFile(multipartFile, 1, 0, UserRegisterParams.class);
        System.out.println(users);
        return users;
    }
}
